#!/usr/bin/env node

import API from '@3-/ragapi'
import { walkRel } from '@3-/walk'
import { join } from 'path'
import read from '@3-/read'

const DIR_DATA = join(import.meta.dirname, 'data/docs');
for await (
  const path of walkRel(DIR_DATA)
) {
  if(!path.endsWith('.md')) continue;
  const txt = read(join(DIR_DATA,path)), id = +path.split('-').pop().slice(0,-3);
  console.log(path);
  await API.index({
    id, 
    repo_id: 201, 
    user_id: 301 ,
    txt
  })
}
